package com.itheima.spring.bestpractive.mapping;

import com.itheima.spring.bestpractive.pojo.Employee;
import com.itheima.spring.bestpractive.pojo.UserRole;
import com.itheima.spring.bestpractive.vo.req.employee.EmpLogin2ReqVo;
import com.itheima.spring.bestpractive.vo.req.employee.EmpReqVo;
import com.itheima.spring.bestpractive.vo.req.employee.EmpUpdataVo;
import com.itheima.spring.bestpractive.vo.resp.employee.EmpRespVo;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @version 1.0
 * @author: HZY
 * @date: 2025/6/25 14:20
 * @Content:
 */
@Mapper
public interface EmpMapping {
    @Operation(description = "获取成员全部信息")
    EmpRespVo getEmp(EmpReqVo empReqVo);
    @Operation(description = "添加成员")
    long insertEmp(Employee  employee);
    @Operation(description = "添加关联")
    void insertEmpRoleRelation(long employeeId);
    @Operation(description = "获取成员角色")
    List<UserRole> getEmpRole(long employeeId);
    @Operation(description = "获取全部的部门考核人员")
    public List<EmpRespVo> getAllEvaluator();
    @Operation(description = "更新登录时间")
    void updateLoginTime(long employeeId);
    @Operation(description = "跟新上次登录时间")
    void updateLastLoginTime(long employeeId);
    @Operation(description = "获取全部员工")
    List<EmpRespVo> getAllEmp(int pageNum, int pageSize);
    @Operation(description = "根据员工编号和电话获取员工信息")
    @Select("select employee_id from employee where id_card=#{idCard} and phone=#{phone}")
    Long getEmpByPhoneAndId(EmpLogin2ReqVo empLogin2ReqVo);
    @Operation(description = "根据员工编号，更改员工密码")
    @Update("update employee set password=HEX((AES_ENCRYPT(#{password}, 'huang_zong_yuan_wu_di'))) where employee_id=#{employeeId}")
    void updateEmpPassword(Employee employee);
    @Operation(description = "修改员工信息")
    void updateEmp(Employee employee);
    @Operation(description = "修改员工信息")
    @Update("update employee_role_relation set  role_id = #{roleId} where employee_id = #{employeeId}")
    void updateEmp2(EmpUpdataVo empVo);

    @Operation(description = "根据员工编号和计划编号修改计划的状态")
    @Update("update employee_indicator_score set status = #{status} where plan_id = #{planId} and employee_id = #{employeeId}")
    void updatePlanStatus(@Param("planId") long planId, @Param("employeeId") long employeeId, @Param("status") int status);
}
